﻿using CommunityToolkit.Mvvm.Input;
using NewWms.Apiservice;
using NewWms.Apiservice.Dto;
using NewWms.Apiservice.InPut;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NewWms.ViewModels
{
    public partial class RecordViewViewModel : BindableBase, INavigationAware
    {

        private readonly IBaseService baseService;
        private readonly IViewService viewService;

        public  RecordViewViewModel() 
        { 
           baseService = new BaseService();
           viewService = new ViewService();
          InPut_ViewService7=new InPut_ViewService7();
            LognoteDtos = new List<lognoteDto>();

        }

        private InPut_ViewService7 inPut_ViewService7;
        public InPut_ViewService7 InPut_ViewService7
        {
            get { return inPut_ViewService7; }
            set { inPut_ViewService7 = value; RaisePropertyChanged(); }
        }
        private List<lognoteDto> lognoteDtos;
        public List<lognoteDto> LognoteDtos
        {
            get { return lognoteDtos; }
            set { lognoteDtos = value; RaisePropertyChanged(); }
        }
        private long count;
        public long Count
        {
            get { return count; }
            set { count = value; RaisePropertyChanged(); }
        }
        private long pagecount;
        public long PageCount
        {
            get { return pagecount; }
            set { pagecount = value; RaisePropertyChanged(); }
        }
        [RelayCommand]
        private async void View_LogNote()
        {
    
            Tuple<List<lognoteDto>, long?, long?> tuple = await  viewService.View_LogNote(InPut_ViewService7);
            if (tuple.Item1 != null)
            {
                LognoteDtos = tuple.Item1;
                Count = (long)tuple.Item2;
                PageCount = (long)tuple.Item3;
            }
        }
        private string title = "出入库记录";
        public string Title
        {
            get { return title; }
            set { title = value; RaisePropertyChanged(); }
        }
        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }
        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
           
        }
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            InPut_ViewService7.PageIndex = 1;
            InPut_ViewService7.PageSize = 50;
            InPut_ViewService7.Type = "入库";
            View_LogNote();
        }
    }
}
